Repository navigation
#408 - Regular expressions: validate the patterns with the configuration, throw on PCRE errors instead of "no match" - #409
Merged
Merged
Conversation
…ion, throw on PCRE errors instead of "no match" Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ends on the PHP version Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #408.
New internal
Regexhelper:validate()compiles a pattern (preg_match($pattern, ''), the warning captured by a temporary error handler, the application handler restored) and throws anInvalidOptionsExceptionnaming the option and the PCRE error.checkLastError()throws anUnexpectedValueExceptionwithpreg_last_error_msg()when the last PCRE call has failed.Used by:
preg_match(pattern): validated; afalseresult ofpreg_match()/preg_match_all()is checked.preg_filter(pattern, string or list of strings): validated; anullresult is checked, so "no match" still givesnull.slugify(replace): validated; anullresult ofpreg_replace()is checked (it gave an empty slug).ConditionTrait:match_regexp,not_match_regexpoffilter,column_aggregator,array_filter,unset): validated (a non-string pattern is rejected too); afalseresult is checked. Until now, it excluded the input with both options.Requirements
Breaking changes
None in the API. An invalid pattern now fails when the options are resolved, instead of filtering every input out (or a PHP warning, an exception in debug mode only). A PCRE error on a value now fails the transformer or task, instead of giving the "no match" result.
🤖 Generated with Claude Code